Generated code - CommonDaoBase functionality

Preface

Every SelfServicing generated set classes has one class which controls a couple of global settings for the application: CommonDaoBase.cs/vb, located in the DaoClasses namespace. Below are the options it offers as static (shared) options.

Connection strings

The CommonDaoBase class lets you set the global connection string to use for every connection to the database. This setting overrides the connection string read from the appSettings section in the .config file. Once the setting is set, every connection to the database uses the set connection string. You set the connection string to use at runtime using the following code:

// C#
CommonDaoBase.ActualConnectionString = "Datasource=myserver;....";
' VB.NET
CommonDaoBase.ActualConnectionString = "Datasource=myserver;...."

If you want to make the application use the connection string defined in the config file again, simply set the ActualConnectionString property to string.Empty.

Command timeouts

If you want to set the ADO.NET command timeout to a value other than the default of 30 seconds, use the CommonDaoBase.CommandTimeOut property to set it to a different value. This will change the timeout immediately for all calls to the database.

note Note:
Firebird doesn't support command timeouts.

ArithAbort flag (SqlServer only)

If an entity is saved into a table which is part of an indexed view, SqlServer requires that SET ARITHABORT ON is specified prior to the actual save action. You can tell LLBLGen Pro to set that option, by calling the global method CommonDaoBase.SetArithAbortFlag(bool) method. After each SQL statement a SET ARITHABORT OFF statement will be executed if the ArithAbort flag is set to true. Setting this flag affects all INSERT statements following the call to SetArithAbortFlag(), until you call that method again.

DQE Compatibility mode(SqlServer / Firebird only)

To set the compatibility mode of the SqlServer DQE or Firebird DQE in code, you can use the CommonDaoBase method SetSqlServerCompatibilityLevel, as shown in the following example which sets the compatibility mode to SqlServer 2005:

// C#
CommonDaoBase.SetSqlServerCompatibilityLevel( SqlServerCompatibilityLevel.SqlServer2005 );
' VB.NET
CommonDaoBase.SetSqlServerCompatibilityLevel( SqlServerCompatibilityLevel.SqlServer2005 )

The default is SqlServer2005. See for more details about that parameter Generated code - Application configuration through .config files.

Setting the compatibility level controls the sequence retrieval logic to use by default (@@IDENTITY on Sqlserver 7 or SCOPE_IDENTITY() on 2000/2005/2008), the ability to use NEWSEQUENTIALID() (SqlServer 2005+) and the SQL produced for a paging query: a temptable approach is used on SqlServer 7 or 2000, and a CTE approach is used on SqlServer 2005+

LLBLGen Pro v3.0 documentation. ©2010 Solutions Design